﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hospital.BLL.IBLL;
using Hospital.Dao.IDao;
using Hospital.Model;
using System.Data;

namespace Hospital.BLL.BLLImpl
{
    public class UserServiceImpl : IUserService
    {
        #region Member
        private IUserDao userDao;
        #endregion

        #region Public Property
        public IUserDao UserDao
        {
            get { return userDao; }
            set { userDao = value; }
        }
        #endregion

        #region IUserService Member
        public IList<User> GetAllUsers()
        {
            return UserDao.GetAllUsers();
        }

        public bool UpdateUser(User user)
        {
            return UserDao.UpdateUser(user);
        }

        public bool DeleteUser(User user)
        {
            return UserDao.DeleteUser(user);
        }

        public bool AddUser(User user)
        {
            return UserDao.AddUser(user);
        }

        public bool UpdateOrAddUser(User user)
        {
            return UserDao.AddOrUpdateUser(user);
        }

        public User GetUserById(int id)
        {
            return UserDao.GetUserById(id);
        }

        public DataTable GetAllUser()
        {
            return userDao.GetAllUser();
        }

        public User UserLogin(string strUserName, string strPassword)
        {
            User user = userDao.GetUserByName(strUserName);
            if (user != null)
            {
                if (user.UserName.Equals(strUserName) && user.Password.Equals(strPassword))
                    return user;
                else
                    return null;
            }
            else
                return null;
        }
        #endregion
    }
}
